<template>
  <div class="merchant alltable">
    <div class="tabbar">
      <div class="let">
            <Button @click="back" class="btn_default" >
            返回
            </Button> 
        <!-- <DatePicker
          type="date"
          placement="bottom-end"
          v-model="data_axios.startday"
          value = 'yyyy-MM-dd'
          placeholder="请选择开始日期"  
          style="width: 130px"
        ></DatePicker>&nbsp;
        <DatePicker
          type="date"
          placement="bottom-end"
          v-model="data_axios.endday"
          placeholder="请选择结束日期"
          style="width: 130px"
        ></DatePicker>&nbsp;        
        <Input
          prefix="ios-search"          
          v-model.trim="data_axios.selectinfo"
          placeholder="请输入关键字"
          style="width: 200px"
        />
        <Button class="btn_default" @click="search">
          <Icon type="ios-search" size="17" class="icon_wy"/>查询
        </Button> -->
      </div>
        <div class='rit'>               
            <Button @click="export_details"><Icon type="ios-cloud-download" size="17" class="icon_wy"/>导出</Button>
      </div>
    </div>
    <div class="tabble">
      <div>
        <Table
          :columns="columns"
          :loading="loading"
          height="560"
          :data="data.datas"
          class="sel_table"
        ></Table>
      </div>
    </div>

    <div class="tab_pages">
      <!-- <Page
        :total="data.allCount"
        :page-size="data_axios.pagesize"
        :current.sync="data_axios.pagenumber"
        show-total
        @on-change="merchant_data"
      >
      </Page> -->
    </div>
   
  </div>
</template>
<script>
import { setAdmin, setToken, getAdmin } from "../../../utils/auth.js";
import { selectSettleDet,settleExport} from "../../../apis/api_system.js";
import filter from './../../../filters/filter';
import down from './../../../comm/down'
export default {
  name: "bus_listing",
  data() {
    return {
      userId: "",
      value: "",
      userName:"",
      data: {
        allCount: 0,
        currPage: 1,
        datas: [],        
      },
      data_axios: {
        id:""     
      },
      
      loading: false,
      Mnamelist: [],
      typelist: [
        {
          mid: 0,
          cname: "商户下单"
        },
        {
          mid: 1,
          cname: "扫码"
        }
      ],
      //   1 2已退款
      billstatuslist: [
        {
          mid: 1,
          cname: "已完成"
        },
        {
          mid: 2,
          cname: "已退款"
        }
      ],
      columns: [
        {
          title: "序号",
          key: "name",
          type: "index",
          width: 50
        },
        {
          title: "商户名",
          key: "cname"
        },
        {
          title: "结算单明细号",
          key: "id"
        },
        {
          title: "经营者名",
          key: "mname",
        //    width: 100
        },
        
        {
          title: "订单金额",
          key: "paymentamt",
        //   width: 100
        },
        {
          title: "手续费 ",
          key: "poundage"
        //   ,
        //   width: 100
        },        
        {
          title: "费率 ",
          key: "rate"
        //   ,
        //   width: 100
        },
        {
          title: "结算金额 ",
          key: "settleamt",
        //    width: 200
        },
        {
          title: "结算条数 ",
          key: "settlecount",
            // width: 150
        },
        {
          title: "时间",
          key: "startday",
          render: (h, params) => {
            const row = params.row;
            // 1已完成 2已退款
            const text = row.startday+'至'+ row.endday;
            return <span>{text}</span>;
          }
        },       
        
        
      ],
      
    };
  },
  
  mounted() {
    this.data_axios.id = this.$route.query.id   ;  
    let info = getAdmin();   
    this.userId = info.id;
    this.userName = info.name;        
    this.to_detail(this.data_axios);
  },
  methods: {     
    // 查看详情
    to_detail(info){
        let data = JSON.stringify({
          requestString: JSON.stringify(info),
          userId: this.userId,
          fullname: "结算单列表"
        });
        console.log(data)
       selectSettleDet(data).then(({ returnString, code, disp}) => { 
          if (code == 200) {    
              // console.log(JSON.parse(returnString));
              this.data.datas = JSON.parse(returnString);
          }else{
               this.$Message.warning(disp);
          }
        })
        .catch(err => {
            this.$Message.warning('请求出错');
        });
    },
    back(){
        this.$router.push("/statement_list");
    },
    export_details(){
      debugger
      let data ={
          requestString: JSON.stringify(this.data_axios),
          userId: this.userId,
          fullname: "结算单列表"
        };
        console.log(data);        
           down("结算单明细.xls",'/verify/settle/settleExport',data);
            //  down("结算单明细.xls",settleExport);
              // console.log(JSON.parse(returnString));
              // this.data.datas = JSON.parse(returnString);
          
        
    }

    
    
    
    
  }
};
</script>